/**
 * Copyright 2011 Enjoy Change, Inc. All rights reserved.
 * Use is subject to license terms.
 */
package com.enjoychange.enjoy.common.tool;

/**
 * 
 * @author l90003709
 *
 */
public final class SQLString {
   
	public static final String ACCOUNT_INSERT_SQL="INSERT INTO account (id,email,password,firstname,lastname)" +
			" VALUES (NULL,:email,:password,:firstname,:lastname) ";
	
	public static final String ACCOUNT_EXIST_SQL="select count(0) from account where email=:email ";
	
	public static final String ACCOUNT_EXIST_UPDTE_SQL="select count(0) from account where email=:email and id!=:id";
	
	public static final String ACCOUNT_QUERY_SQL="select * from account where email=:email ";
	
	
	public static final String STORYCASE_INSERT_SQL="INSERT INTO storycase (storyid,title,specification,newtime) VALUES (:storyid,:title,:specification,:newtime) ";
	
	public static final String STORYCASE_UPDATE_SQL="UPDATE storycase SET title =:title, specification =:specification,newtime=:newtime WHERE storyid =:storyid";
	
	public static final String STORYCASE_QUERY_SQL="SELECT * from  storycase WHERE storyid =:storyid order by newtime desc";
	public static final String STORYCASE_DELETE_SQL="DELETE  from  storycase WHERE storyid =:storyid";

	public static String getNoWhereSql(String storycaseQuerySql) {
		int whereIndex=storycaseQuerySql.indexOf("WHERE");
		if(whereIndex==-1){
			whereIndex=storycaseQuerySql.indexOf("where");
		}
		return storycaseQuerySql.substring(0,whereIndex);
	}
	
	public static void main(String[] arr){
		System.out.println(getNoWhereSql(ACCOUNT_QUERY_SQL));
	}
}
